<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>添加</title>
    <#assign base=request.contextPath  />
    <base id="base" href="${base}">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, adminUser-scalable=0">
    <link rel="stylesheet" href="${base}/static/win10/component/layui/css/layui.css" media="all">
    <script>
        var base =  "${base}";
    </script>
</head>
<body>
<br>
<form class="layui-form " action="">
         <input type="hidden" id="enclosureId" name="enclosureId" value="${wechatEnclosure.enclosureId!}" >
          <div class="layui-form-item">
              <label class="layui-form-label">简历附件地址</label>
              <div class="layui-input-block">
                  <input type="text" id="enclosureUrl" name="enclosureUrl" value="${wechatEnclosure.enclosureUrl!}"  autocomplete="off" placeholder="请输入简历附件地址"
                         class="layui-input">
                  <#if "${wechatEnclosure.enclosureUrl!}"?length gt 0>
                      <button type="button" class="layui-btn" onclick="PreviewImg('${wechatEnclosure.enclosureUrl!}')">预览</button>
                  </#if>
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">选择用户</label>
              <div class="layui-input-block">
                  <@personal_tag >
                      <select name="userId" lay-filter="userId" id="userId">
                          <option value="">请选择</option>
                          <#if personalList?? && personalList?size gt 0>
                              <#list personalList as dict>
                                  <#if '${dict.personalId}'=='${wechatEnclosure.userId!}'>
                                            <option value="${dict.personalId}" selected>${dict.personalName}</option>
                                      <#else >
                                            <option value="${dict.personalId}">${dict.personalName}</option>
                                  </#if>
                              </#list>
                          </#if>
                      </select>
                  </@personal_tag>
              </div>
          </div>

    <div align="center">
        <button type="button" class="layui-btn" id="submit">保存</button>
    </div>
</form>

<script src="${base}/static/win10/component/layui/layui.js?t=1"></script>
<script src="${base}/static/win10/js/jquery-1.8.3.min.js?t=1"></script>
<script>
    layui.use(['form', 'layer'], function() {
        var form = layui.form
                , layer = layui.layer;
        $("#submit").on("click",function () {
            if(check()===false){
                return;
            }

            var formDate = {
                         enclosureId:$("#enclosureId").val(),
                         enclosureUrl:$("#enclosureUrl").val(),
                           userId:$("#userId").val()
            }
            $.ajax({
                type: "POST",
                url: base+"/WeChatUser/wechatEnclosure/admin/editWechatEnclosure",
                data: formDate,
                success: function (data) {
                    layer.msg(data.message)
                    if (data.code === 200) {
                        window.location.href=base+"/WeChatUser/wechatEnclosure/admin/main.html"
                    } else {

                    }
                }
            });
        })

        function check(){
                   if($("#enclosureUrl").val().length<1){
                       layer.msg("请输入简历附件地址");
                       return false;
                   }
                   if($("#userId").val().length<1){
                       layer.msg("请输入用户Id");
                       return false;
                   }
        }
    });

    function PreviewImg(value) {
        layui.use('layer', function () {
            var layer = layui.layer;
            layer.open({
                type: 2,
                area: ['1000px', '750px'],
                fixed: false, //不固定
                maxmin: true,
                content: value
            });
        });
    }

</script>
</body>
</html>